
package com.tenentia.pcmps.swm.data.implementation;

import org.apache.log4j.Logger;

import com.tenentia.pcmps.swm.Constants;
import com.tenentia.pcmps.swm.data.DataAccessException;
import com.tenentia.pcmps.swm.data.DataAccessObjectsFactory;
import com.tenentia.pcmps.swm.data.DataAccessObject;

/**
 * 
 * @author tEnEntia, S.L.N.E.
 * 
 */
public class DataAccessObjectsFactoryImpl extends DataAccessObjectsFactory {

	private static final Logger LOGGER = Logger.getLogger(DataAccessObjectsFactoryImpl.class.getPackage().getName());

	private static DataAccessObjectsFactoryImpl staticInstance;

	static {

		staticInstance = new DataAccessObjectsFactoryImpl();
	}

	private DataAccessObjectsFactoryImpl() {

		super();
	}

	public static DataAccessObjectsFactory getInstance() {

		return staticInstance;
	}

	public DataAccessObject createNewDataAccessObject(Integer dataAccessObjectType) throws DataAccessException {

		LOGGER.trace(Constants.STRING_L4J_METHOD_BEGIN);

		if (null == dataAccessObjectType) {
			throw new DataAccessException("Null parameter");
		} else {
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.BONUS_DAO)) {
				return new BonusDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.GROUPS_DAO)) {
				return new GroupsDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.INSURANCE_POLICIES_DAO)) {
				return new InsurancePoliciesDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.MARKETING_PROMOTIONS_DAO)) {
				return new MarketingPromotionsDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.PDF_TEMPLATES_DAO)) {
				return new PDFTemplatesDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.PERSONS_DAO)) {
				return new PersonsDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.ROLES_DAO)) {
				return new RolesDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.STATES_DAO)) {
				return new StatesDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.WAY_TYPES_DAO)) {
				return new WayTypesDAOImpl();
			}
			if (dataAccessObjectType.equals(DataAccessObjectsFactory.PARAMETERS_DAO)) {
				return new ParametersDAOImpl();
			}

			throw new DataAccessException("Unknown parameter");
		}
	}
}
